/*
 * @lc app=leetcode id=461 lang=cpp
 *
 * [461] Hamming Distance
 */

// @lc code=start
class Solution {
public:
    int hammingDistance(int x, int y) {
        int a = x >= y ? x : y;
        int b = x >= y ? y : x;
        int res = 0;
        while (a > 0) {
            res += (a & 1) == (b & 1) ? 0 : 1;
            a >>= 1;
            b >>= 1;
        }
        return res;
    }
};
// @lc code=end

